package Models

type GZGoods struct {
	Id                   int64   `json:"id" gorm:"primary_key"`
	Title                string  `json:"title" gorm:"size:255"`
	GoodsType            int     `json:"goods_type" gorm:"index:goods_type;size:255;comment:'商品类型 1:视频课 2:音频课 3:直播 4:图文课 5:系列课 6:套餐 7:会员卡 8:活动 9:题库（没写入goods表）10:电子书'"`
	CateId               int64   `json:"cate_id" gorm:"index:cate_id;comment:'课程分类id'"`
	GoodsCategory        int64   `json:"goods_category" gorm:"column:goods_category; commit:'二级分类 1 训练营 2 就业班  3 大班课 4 随时学'"`
	GoodsMode            string  `json:"goods_mode" gorm:"commit:'课程类型 1理论 2实战'"`
	JobId                int64   `json:"job_id" gorm:"commit:'作业id'"`
	EbookCateId          int64   `json:"ebook_cate_id" gorm:"index;type:int;comment:'书籍分类id'"`
	GoodsName            string  `json:"goods_name" gorm:"index;size:100;commit:'商品名称'"`
	GoodsSn              string  `json:"goods_sn" gorm:"index;size:20;commit:'商品编号'"` // 直接标明是index索引字段，也可以index:索引名称
	Author               string  `json:"author" gorm:"size:50;commit:'书籍作者'"`
	ReadNum              int64   `json:"read_num" gorm:"commit:'阅读人数'"`
	ReadOutNum           int64   `json:"read_out_num" gorm:"commit: 阅读完成人数"`
	ShareNum             int64   `json:"share_num" gorm:"commit:'转发人数'"`
	Views                string  `json:"views" gorm:"commit:浏览人数"`
	Price                float64 `json:"price" gorm:"type:decimal(10,2);commit:'价格'"`
	AnnexId              int64   `json:"annex_id" gorm:"commit:'素材库音视频id'"`
	TryAnnexId           int64   `json:"try_annex_id" gorm:"commit:'试看素材库音视频id'"`
	ThumbId              int64   `json:"thumb_id" gorm:"commit:'缩略图id'"`
	VirtualViews         int64   `json:"virtual_views" gorm:"commit:'虚拟浏览量'"`
	BuyNum               int64   `json:"buy_num" gorm:"commit:'购买人数'"`
	VirtualByNum         int64   `json:"virtual_buy_num" gorm:"commit:'虚拟购买人数'"`
	StudyNum             int64   `json:"study_num" gorm:"commit:'学习人数'"`
	StudyOutNum          int32   `json:"study_out_num" gorm:"commit:'学完人数'"`
	IsAlone              int     `json:"is_alone" gorm:"commit '单独售卖 0:未开启 1:开启'"`
	IsVipFree            int     `json:"is_vip_free" gorm:"commit '会员vip免费 0:否 1:是'"`
	IsBest               int     `json:"is_best" gorm:"commit '是否是精品  0:否 1:是'"`
	IsTop                int     `json:"is_top" gorm:"commit '是否置顶1默认，2置顶'"`
	IsHot                int     `json:"is_hot" gorm:"commit '是否热销  0:否 1:是'"`
	Ptype                int     `json:"ptype" gorm:"commit '1正价 2体验 3会员'"`
	IsNew                int     `json:"is_new" gorm:"commit '是否新品 0:否 1:是'"`
	ShareTitle           string  `json:"share_title" gorm:"size:200; commit '分享标题'"`
	ShareDesc            string  `json:"share_desc" gorm:"type:text; commit '分享说明'"`
	ShareIconId          int64   `json:"share_icon_id" gorm:"commit:'分享图标 素材库id'"`
	ExpireMonth          int64   `json:"expire_month" gorm:"commit:'有效期  0:7天  其他:正整数月份'"`
	ZdyMonth             int64   `json:"zdy_month" gorm:"commit:'自定义月份'"`
	IsEnable             int     `json:"is_enable" gorm:"commit:'1:上架  0:下架'"`
	IsShow               int     `json:"is_show" gorm:"commit:'店铺显示 1是'"`
	IsCopy               int     `json:"is_copy" gorm:"commit:'1:禁止复制文字  0:允许复制文字'"`
	IsTraining           int     `json:"is_training" gorm:"commit:'是否训练营'"`
	JobType              int     `json:"job_type" gorm:"commit:'作业类型  1 作业 2 测试题'"`
	Orderby              int     `json:"orderby" gorm:"commit:'排序'"`
	ComplexOrderby       float64 `json:"complex_orderby" gorm:"type:decimal(10,2);commit:'综合排序'"`
	OnlineSaleMoney      float64 `json:"online_sale_money" gorm:"type:decimal(10,2);commit:'线上销售总金额'"`
	Thumb                string  `json:"thumb" gorm:"commit:'课程图片地址'"`
	ThumbHeight          int64   `json:"thumb_height" gorm:"commit:'图片高度'"`
	ThumbWidth           int64   `json:"thumb_width" gorm:"commit:'图片宽度'"`
	ReleaseTime          int64   `json:"release_time" gorm:"commit:'上线时间'"`
	SettlementTid        int64   `json:"settlement_tid" gorm:"commit:'结算老师id'"`
	SettlementProportion float64 `json:"settlement_proportion" gorm:"commit:'结算比例小数点'"`
	OpenClassTime        int64   `json:"open_class_time" gorm:"commit:'开班时间'"`
	SzCourseId           int64   `json:"sz_course_id" gorm:"commit:'深造课程ID'"`
	CourseTp             int     `json:"course_tp" gorm:"commit:'课程内容类型 0默认 1综合 2实验'"`
	Closed               int64   `json:"closed"`
	CreatedAt            int64   `json:"create_time"`
	UpdatedAt            int64   `json:"update_time"`
}

func (GZGoods) TableName() string {
	return "gz_goods"
}

func GetEveryOneGoodsInfo(w any) GZGoods {
	var r GZGoods
	DB.Where(w).Find(&r)
	return r
}

func GetGoodsCount(w any) int64 {
	var r int64
	DB.Where(w).Count(&r)
	return r
}
